package View;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import Controller.AddAccount;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class PanelAddAccount extends JPanel {

	private static PanelAddAccount single;

	private JLabel formName = new JLabel("Rekening toevoegen");
	private JLabel accountNumber = new JLabel("IBAN : ");
	private JLabel accountType = new JLabel("Rekening type : ");

	private JLabel accountName = new JLabel("Rekening beschrijving : ");
	private JLabel accountRent = new JLabel("Rekening rente : ");
	private JLabel accountAmount = new JLabel("Huidige saldo van rekening : ");

	private JTextField accountNumberField = new JTextField();
	private JTextField accountTypeField = new JTextField();
	private JTextField accountNameField = new JTextField();
	private JTextField accountRentField = new JTextField();
	private JTextField accountAmountField = new JTextField();

	private JButton confirmButton = new JButton("Toevoegen");
	private JButton terugButton = new JButton("Overzicht");

	private Color backcolor = new Color(239, 238, 237);
	private Color titleColor = new Color(85, 85, 85);

	private PanelAddAccount() {

		AddAccount cal = new AddAccount(this);

		setLayout(null);
		setBounds(140, 0, 860, 725);
		setBackground(backcolor);

		formName.setBounds(330, 30, 200, 30);
		formName.setForeground(titleColor);
		formName.setFont(new Font("Serif", Font.BOLD, 20));

		accountNumber.setBounds(80, 70, 200, 30);
		accountType.setBounds(80, 110, 200, 30);
		accountName.setBounds(80, 150, 200, 30);
		accountRent.setBounds(80, 190, 200, 30);
		accountAmount.setBounds(80, 230, 200, 30);

		accountNumberField.setBounds(300, 70, 200, 30);
		accountTypeField.setBounds(300, 110, 200, 30);
		accountNameField.setBounds(300, 150, 200, 30);
		accountRentField.setBounds(300, 190, 200, 30);
		accountAmountField.setBounds(300, 230, 200, 30);

		confirmButton.setBounds(91, 289, 100, 30);
		confirmButton.setActionCommand("Toevoegen");
		confirmButton.addActionListener(cal);

		terugButton.setBounds(320, 289, 110, 30);
		terugButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				PanelHolder mf = PanelHolder.getInstance();
				mf.remove(PanelAddAccount.getInstance());
				mf.add(PanelAccountView.getInstance());
				mf.repaint();
				mf.validate();
			}
		});

		add(formName);
		add(accountNumber);
		add(accountType);
		add(accountName);
		add(accountRent);
		add(accountAmount);

		add(accountNumberField);
		add(accountTypeField);
		add(accountNameField);
		add(accountRentField);
		add(accountAmountField);

		add(confirmButton);
		add(terugButton);

	}

	public JLabel getAccountNumber() {
		return accountNumber;
	}

	public void setAccountNumber(JLabel accountNumber) {
		this.accountNumber = accountNumber;
	}

	public JLabel getAccountAmount() {
		return accountAmount;
	}

	public void setAccountAmount(JLabel accountAmount) {
		this.accountAmount = accountAmount;
	}

	public JTextField getAccountNumberField() {
		return accountNumberField;
	}

	public void setAccountNumberField(JTextField accountNumberField) {
		this.accountNumberField = accountNumberField;
	}

	public JTextField getAccountAmountField() {
		return accountAmountField;
	}

	public void setAccountAmountField(JTextField accountAmountField) {
		this.accountAmountField = accountAmountField;
	}

	public JButton getTerugButton() {
		return terugButton;
	}

	public void setTerugButton(JButton terugButton) {
		this.terugButton = terugButton;
	}

	public static PanelAddAccount getInstance() {
		if (single == null) {
			single = new PanelAddAccount();
		}
		return single;
	}

	public static void selfDestroy() {
		single = null;
	}

	public static PanelAddAccount getSingle() {
		return single;
	}

	public static void setSingle(PanelAddAccount single) {
		PanelAddAccount.single = single;
	}

	public JLabel getFormName() {
		return formName;
	}

	public void setFormName(JLabel formName) {
		this.formName = formName;
	}

	public JLabel getAccount() {
		return accountNumber;
	}

	public void setAccount(JLabel account) {
		this.accountNumber = account;
	}

	public JLabel getAccountType() {
		return accountType;
	}

	public void setAccountType(JLabel accountType) {
		this.accountType = accountType;
	}

	public JLabel getAccountName() {
		return accountName;
	}

	public void setAccountName(JLabel accountName) {
		this.accountName = accountName;
	}

	public JLabel getAccountRent() {
		return accountRent;
	}

	public void setAccountRent(JLabel accountRent) {
		this.accountRent = accountRent;
	}

	public JLabel getAccountRentPeriod() {
		return accountAmount;
	}

	public void setAccountRentPeriod(JLabel accountRentPeriod) {
		this.accountAmount = accountRentPeriod;
	}

	public JTextField getAccountField() {
		return accountNumberField;
	}

	public void setAccountField(JTextField accountField) {
		this.accountNumberField = accountField;
	}

	public JTextField getAccountTypeField() {
		return accountTypeField;
	}

	public void setAccountTypeField(JTextField accountTypeField) {
		this.accountTypeField = accountTypeField;
	}

	public JTextField getAccountNameField() {
		return accountNameField;
	}

	public void setAccountNameField(JTextField accountNameField) {
		this.accountNameField = accountNameField;
	}

	public JTextField getAccountRentField() {
		return accountRentField;
	}

	public void setAccountRentField(JTextField accountRentField) {
		this.accountRentField = accountRentField;
	}

	public JTextField getAccountRentPeriodField() {
		return accountAmountField;
	}

	public void setAccountRentPeriodField(JTextField accountRentPeriodField) {
		this.accountAmountField = accountRentPeriodField;
	}

	public JButton getConfirmButton() {
		return confirmButton;
	}

	public void setConfirmButton(JButton confirmButton) {
		this.confirmButton = confirmButton;
	}

}
